/**
 * 自定义下拉列表
 * 
 * @param valueMap
 *            下拉列表值 key：value显示的字段
 * @param field
 *            用于选定值后写入value
 * @param keyField
 *            用于选定值后写入key
 */
function addMySelectPlugin(valueMap, field, keyField) {
	var div = document.createElement("DIV");
	div.className = 'mySelectPluginDiv';
	var pos = getElemPos(field);
	div.style.left = pos.x;
	div.style.top = pos.y + 22;
	for ( var key in valueMap) {
		div.appendChild(createAnchor(key, valueMap[key], function() {
			document.body.removeChild(div);
			field.onblur = null;
		}, field, keyField));
	}
	document.body.appendChild(div);
	var over = false;
	div.onmouseover = function() {
		over = true;
	};
	div.onmouseout = function() {
		over = false;
	};
	field.onblur = function() {
		if (!over) {
			document.body.removeChild(div);
			field.onblur = null;
		}
	};
}
function createAnchor(key, value, operate, field, keyField) {
	var a = document.createElement("a");
	a.href = "javascript:void(0)";
	a.innerHTML = value;
	a.onclick = function() {
		field.value = this.innerHTML;
		if (keyField) {
			keyField.value = key;
		}
		if ((typeof operate).toLowerCase() == 'function') {
			operate();
		}
	};
	return a;
}
/**
 * 获取dom坐标
 * 
 * @param obj
 * @returns {___anonymous384_420}
 */
function getElemPos(obj) {
	var pos = {
		"top" : 0,
		"left" : 0
	};
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			pos.top += obj.offsetTop;
			pos.left += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		pos.left += obj.x;
	} else if (obj.x) {
		pos.top += obj.y;
	}
	return {
		x : pos.left,
		y : pos.top
	};
}
